#include <bits/stdc++.h>
using namespace std;
int d[100005], v[100005], a[100005];
int p[100005];
bool fast[25][25];
int num[25];
int main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int T;
    cin >> T;
    while(T--) {
        int ans1 = 0;
        int n, m, l, V;
        cin >> n >> m >> l >> V;
        memset(d, 0, sizeof(d));
        memset(v, 0, sizeof(v));
        memset(a, 0, sizeof(a));
        memset(p, 0, sizeof(p));
        for(int i=1; i<=n; i++) {
            cin >> d[i] >> v[i] >> a[i];
        }
        for(int i=1; i<=m; i++) {
            cin >> p[i];
        }
        int ans2 = m;
        for(int i=1; i<=n; i++) {
            if(v[i] <= V && a[i] <= 0) continue;
            else if(v[i] > V && a[i] >= 0 && d[i] <= p[m]){
                ans1++;
            }
            else if(v[i] > V && a[i] < 0) {
                for(int j=1; j<=m; j++) {
                    if(p[j] >= d[i]) {
                        if(sqrt(v[i]*v[i]+2*a[i]*(p[j]-d[i])) > V){
                            ans1++;
                            break;
                        }
                    }
                }
            } else if(v[i] <= V && a[i] > 0) {
                if(sqrt(v[i]*v[i]+2*a[i]*(p[m]-d[i])) > V) ans1++;
            }
        }
        if(ans1==0) cout << ans1 << " " << m << endl;
        else cout << ans1 << " " << m-1 << endl;
    }

    fclose(stdin);
    fclose(stdout);
    return 0;
}
